Skip to content

Conversation

@hokein
Copy link
Collaborator

@hokein hokein commented Feb 10, 2025

Fixes #125821

The assertion was too strict, as Clang can reach this code path when recursively generating deduction guides for alias templates. See the detailed explanation here.

No release notes needed, as there is no behavior change in release builds.

@hokein hokein requested review from cor3ntin and shafik February 10, 2025 15:37
@hokein hokein marked this pull request as ready for review February 11, 2025 08:09
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Feb 11, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 11, 2025

@llvm/pr-subscribers-clang

Author: Haojian Wu (hokein)

Changes

Fixes #125821

The assertion was too strict, as Clang can reach this code path when recursively generating deduction guides for alias templates. See the detailed explanation here.

No release notes needed, as there is no behavior change in release builds.


Full diff: https://github.com/llvm/llvm-project/pull/126532.diff

2 Files Affected:

  • (modified) clang/lib/Sema/SemaTemplateDeductionGuide.cpp (-2)
  • (modified) clang/test/SemaCXX/cxx20-ctad-type-alias.cpp (+14)
diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
index e5931f4684a57d..b789824d970208 100644
--- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -998,8 +998,6 @@ getRHSTemplateDeclAndArgs(Sema &SemaRef, TypeAliasTemplateDecl *AliasTemplate) {
       Template = CTSD->getSpecializedTemplate();
       AliasRhsTemplateArgs = CTSD->getTemplateArgs().asArray();
     }
-  } else {
-    assert(false && "unhandled RHS type of the alias");
   }
   return {Template, AliasRhsTemplateArgs};
 }
diff --git a/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp b/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp
index 37dca2215af6ba..832ce15e662508 100644
--- a/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp
+++ b/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp
@@ -525,3 +525,17 @@ template <ArrayType<int>::Array array> void test() {}
 void foo() { test<{1, 2, 3}>(); }
 
 } // namespace GH113518
+
+namespace GH125821 {
+template<typename T>
+struct A { A(T){} };
+
+template<typename T>
+using Proxy = T;
+
+template<typename T>
+using C = Proxy< A<T> >;
+
+C test{ 42 }; // expected-error {{no viable constructor or deduction guide for deduction of template arguments}}
+
+} // namespace GH125821

Copy link
Contributor

@zyn0217 zyn0217 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@hokein hokein merged commit b963d37 into llvm:main Feb 13, 2025
12 checks passed
@hokein hokein deleted the ctad-assertion branch February 13, 2025 11:15
flovent pushed a commit to flovent/llvm-project that referenced this pull request Feb 13, 2025
…TypeAlias (llvm#126532)

Fixes llvm#125821

The assertion was too strict, as Clang can reach this code path when
recursively generating deduction guides for alias templates. See the
detailed explanation
[here](llvm#125821 (comment)).

No release notes needed, as there is no behavior change in release
builds.
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
…TypeAlias (llvm#126532)

Fixes llvm#125821

The assertion was too strict, as Clang can reach this code path when
recursively generating deduction guides for alias templates. See the
detailed explanation
[here](llvm#125821 (comment)).

No release notes needed, as there is no behavior change in release
builds.
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
…TypeAlias (llvm#126532)

Fixes llvm#125821

The assertion was too strict, as Clang can reach this code path when
recursively generating deduction guides for alias templates. See the
detailed explanation
[here](llvm#125821 (comment)).

No release notes needed, as there is no behavior change in release
builds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CTAD for alias template crashes.

3 participants